<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<!--

    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

    Copyright (c) 2010-2013 Oracle and/or its affiliates. All rights reserved.

    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common Development
    and Distribution License("CDDL") (collectively, the "License").  You
    may not use this file except in compliance with the License.  You can
    obtain a copy of the License at
    https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
    or packager/legal/LICENSE.txt.  See the License for the specific
    language governing permissions and limitations under the License.

    When distributing the software, include this License Header Notice in each
    file and include the License file at packager/legal/LICENSE.txt.

    GPL Classpath Exception:
    Oracle designates this particular file as subject to the "Classpath"
    exception as provided by Oracle in the GPL Version 2 section of the License
    file that accompanied this code.

    Modifications:
    If applicable, add the following below the License Header, with the fields
    enclosed by brackets [] replaced by your own identifying information:
    "Portions Copyright [year] [name of copyright owner]"

    Contributor(s):
    If you wish your version of this file to be governed by only the CDDL or
    only the GPL Version 2, indicate your decision by adding "[Contributor]
    elects to include this software in this distribution under the [CDDL or GPL
    Version 2] license."  If you don't indicate a single choice of license, a
    recipient has the option to distribute your version of this file under
    either the CDDL, the GPL Version 2 or to extend the choice of license to
    its licensees as provided above.  However, if you add GPL Version 2 code
    and therefore, elected the GPL Version 2 license, then the option applies
    only if the new code is made subject to such option by the copyright
    holder.

-->

  <title>The File Upload Servlet Sample Application</title>
  <style type="text/css">
  body,th,td,p,div,span,a,ul,ul li, ol, ol li, ol li b, dl,h1,h2,h3,h4,h5,h6,li
  {font-family:geneva,helvetica,arial,"lucida sans",sans-serif; font-size:10pt}
  h1 {font-size:18pt}
  h2 {font-size:14pt}
  h3 {font-size:12pt}
  code,kbd,tt,pre {font-family:monaco,courier,"courier new";font-size:10pt;color:#666}
  li {padding-bottom: 8px}
  p.copy, p.copy a {font-family:geneva,helvetica,arial,"lucida sans",sans-serif; font-size:8pt}
  p.copy {text-align: center}
  </style>
</head>
<body style="color: rgb(0, 0, 0); background-color: rgb(255, 255, 255);"
 alink="#333366" link="#594fbf" marginwidth="10" vlink="#1005fb">
<table border="0" cellpadding="2" cellspacing="4" width="100%">
  <tbody>
    <tr>
      <td align="right" bgcolor="#587993" valign="top"> <font
 color="#ffffff" size="-1"><b>Java EE 7 SDK</b></font>&nbsp;
      </td>
    </tr>
  </tbody>
</table>
<!---- Don't modify anything above this line, except for the title tag -------->
<p><a href="../../../docs/list.html">Samples Main Page<br>
</a></p>
<h1>The File Upload Servlet Sample Application</h1>
<p>This sample application demonstrates how to use the support for multipart (also known as file upload) defined in the Servlet specification.</p>

<h2>Description</h2>
<p>This sample application demonstrates the multipart feature of Servlet 3.0.
The sample contains a simple web page that promts the user for the names of two files
to upload them to the web container. The files are uploaded to a servlet, then the client
is redirected to a JSP page.</p>

<p>Servlet 3.0 enables you to get the contents and attributes
of each part directly using the <code>HttpServletRequest</code> interface.</p>

<p>The <code>getParts.jsp</code> file demonstrates how to use the basic functionality from the 
<code>Part</code> interface.</p>


<h2>Key Features</h2>
<p>This sample demonstrates how to access the attributes and contents of parts directly from the <code>HttpServletRequest</code> interface.</p>

<h2>Building, Deploying, and Running the Application</h2>
<p>
Perform the following steps to build, deploy, and run the
application:</p>
<ol>
  <li> Set up your build environment and configure the application
  server with which the build system has to work by following the <a
 href="../../../docs/UserREADME.html"> common build instructions.</a></li>
  <li><code><i>app_dir</i></code> is the sample application base
  directory: <code><i>samples_install_dir</i>/servlet/multipart-war</code>.</li>
  <li><code></code><code></code>Change directory to <code><i>app_dir.<br>
    </i></code></li>
    <li>Build, deploy, the sample application using the <code>mvn</code> target:
	
	
    <p>Use the command below to run this sample using the Cargo framework:</p>
	<p><code><span style="font-style: italic;">app_dir&gt;</span> 
	mvn clean verify cargo:run </code></p>
	<p>You can point Cargo to an already installed and running Glassfish server:</p>
	<p><code><span style="font-style: italic;">app_dir&gt; </span>mvn clean verify cargo:run -Dglassfish.home=$&lt;glassfish_dir&gt;</code> (e.g. ../glassfish4)</p>
	<p>You can also build and deploy the sample application without Cargo:</p>
	<p><code><span style="font-style: italic;">app_dir&gt; </span>mvn install</code></p>
	<p><code><span style="font-style: italic;">app_dir&gt; </span>asadmin deploy ./target/&lt;app_name&gt;.war</code></p>
  
   </li>
  <li>Test the sample application as follows:<br><br>
    <ul>
      <li>Use the browser to access
<code>http://&lt;javaee.server.name&gt;:&lt;javaee.server.port&gt;/multipart-war/</code>
      
    </ul>
  </li>
  <li>Use the Glassfish <code>asadmin</code> command line utility to undeploy the application.
      <p><code><span style="font-style: italic;">app_dir&gt; </span>
      asadmin undeploy &lt;app_name&gt;</code></p>
  </li>
    <li>Use the <code>clean</code> target to remove the temporary directories
    like <code>/target</code>.
      <p><code><span style="font-style: italic;">app_dir&gt; </span>mvn
      clean</code> </p>
  </li>
</ol>

<h2>Building, Deploying, and Running the Application in NetBeans IDE</h2>
<p>Perform the following steps to build, deploy, and run the application using NetBeans IDE:</p>
<ol>
<li> Refer to the <a href="../../../docs/UserREADME.html"> common build instructions</a> for setting up NetBeans IDE and Java EE 7 SDK.</li>
<li> In the NetBeans IDE, choose File &#8594; Open Project (Ctrl-Shift-O), navigate to the <code><i>samples_install_dir</i>/servlet/</code> directory, select <code>multipart-war</code>, and click Open Project.</li>
<li> In the Projects tab, right click <code>multipart-war</code> and select Run to build, deploy, and run the project.</li>
</ol>

<h2>Troubleshooting</h2>
<p>If you have problems when running the application, refer the <a
 href="../../../docs/UserTroubleShooting.html">
troubleshooting document</a>.
</p>
&nbsp;
<!--- Do not modify the rest of the document -->
<hr noshade="noshade" size="1"><!-- start copyright -->
<p class="copy"> Copyright &copy; 1997-2013 Oracle and/or its affiliates. All rights reserved. </p>
<!--  end copyright  -->
</body>
</html>
